package com.lihepeng.leecode.array;

import org.junit.Test;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Solution1207 {
    public boolean uniqueOccurrences(int[] arr) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < arr.length; i++) {
            if (map.containsKey(arr[i])) {
                map.put(arr[i], map.get(arr[i]) + 1);
            } else {
                map.put(arr[i], 1);
            }
        }
        Set<Integer> times = new HashSet<>();
        map.entrySet().forEach(integerIntegerEntry -> {
            times.add(integerIntegerEntry.getValue());
        });

        return map.size() == times.size();
    }

    @Test
    public void runTest() {
        int[] arrs = {1, 2, 2, 1, 1, 3};
        System.out.println(this.uniqueOccurrences(arrs));
    }
}
